package com.burpee.service;

import java.util.HashMap;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.burpee.dao.FoodDao;
import com.burpee.ui.Food;

@Service(value="foodService")
public class FoodServiceImpl implements FoodService {

	@Autowired
	FoodDao foodDao;

	public List<Food> list(HashMap<String, String> foodchoice) {

		return foodDao.list(foodchoice);
	}


	public Food view(long foodNo) {

		return foodDao.view(foodNo);
	}

	public boolean add(Food food) {
		if(foodDao.add(food) > 0){
			return true;
		}
		else{

			return false;
		}
	}

	public boolean modify(Food food) {
		if(foodDao.modify(food) > 0){
			return true;
		}
		else{

			return false;
		}
	}

	public boolean adminFoodRemove(String[] foodNo) {
		int result = 0;
		
		int checkboxtotal = foodNo.length;
		
		for(int i = 0; i < checkboxtotal; i++){
			result = foodDao.adminFoodremove(foodNo[i]);
		}

		if(result > 0){
			return true;
		}
		else{
			return false;
		}
	}
	
	public boolean adminFoodRemoveCancel(String[] foodNo) {
		int result = 0;
		
		int checkboxtotal = foodNo.length;
		
		for(int i = 0; i < checkboxtotal; i++){
			result = foodDao.adminFoodremoveCancel(foodNo[i]);
		}

		if(result > 0){
			return true;
		}
		else{
			return false;
		}
	}

	public List<Food> foodIngestPurposeSelectList(Food food) {
		// TODO Auto-generated method stub
		return foodDao.foodIngestPurposeSelectList(food);
	}
	public List<Food> foodClassList(){
		return foodDao.foodClassList();
	}

	public List<Food> foodClassficationList(){
		return foodDao.foodClassficationList();
	}


	public int adminfoodCount() {
		
		return foodDao.adminfoodCount();
	}


	public List<Food> adminfoodList(int currentPage) {

		return foodDao.adminfoodList(currentPage);
	}

	
	

}
